package com.springsource.boot.autoConfig;

import cn.hutool.core.util.StrUtil;
import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DeferredImportSelector;
import org.springframework.context.annotation.Import;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.type.AnnotationMetadata;

public class TestAopAuto {

    public static void main(String[] args) {
        GenericApplicationContext context = new GenericApplicationContext();
        AnnotationConfigUtils.registerAnnotationConfigProcessors(context.getDefaultListableBeanFactory());
        context.registerBean(Config.class);
        context.refresh();
        for (String beanDefinitionName : context.getBeanDefinitionNames()) {
//            String resourceDescription = context.getBeanDefinition(beanDefinitionName).getResourceDescription();
//            if (StrUtil.isNotEmpty(resourceDescription)) {
                System.out.println(beanDefinitionName);
//            }
        }
    }

    @Configuration
    @Import(MyImportSelector.class)
    static class Config {
    }


    static class MyImportSelector implements DeferredImportSelector {
        @Override
        public String[] selectImports(AnnotationMetadata importingClassMetadata) {
            return new String[]{AopAutoConfiguration.class.getName()};
        }
    }


}
